<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRepaySummariesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('repay_summaries', function (Blueprint $table) {
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';
            $table->comment = '放款总表';
            $table->increments('id');
            $table->unsignedInteger('uid')->comment('当前用户');
            $table->unsignedInteger('loan_request_id')->comment('授信申请表id')->unique();
            $table->string('loan_id',100)->default('')->comment('新流订单号');
            $table->unsignedInteger('amount')->comment('总金额存分');
            $table->unsignedTinyInteger('period_count')->default(1)->comment('总期数');
            $table->unsignedTinyInteger('period')->default(1)->comment('当前的期数(0代表全部还清)');
            $table->string('rate')->default('')->comment('后台配置,保存json');
            $table->unique(['uid','loan_id']);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('repay_summaries');
    }
}
